<? 
$query = "select * from tbl_company_type";
$result = mysql_query($query);

$query2 = "select * from tbl_rate_type";
$result2 = mysql_query($query2);

$query3 = "select * from tbl_companies";
$result3 = mysql_query($query3);

$query4 = "select * from tbl_whis_carriers";
$result4 = mysql_query($query4);

if($_POST['cmpy_info'] == 'company_info')
{
	extract($_POST);
	$insert_query = "INSERT INTO tbl_companies (c_name,c_nickname,c_billing_address1,c_billing_address2,c_billing_city," .
			"c_billing_state,c_billing_zipcode,c_billing_country,c_phone_number,c_phone_extension,c_fax_number) " .
			"values ('$c_name','$c_nickname','$c_billing_address1','$c_billing_address2','$c_billing_city','$c_billing_state'," .
			"'$c_billing_zipcode','$c_billing_country','$c_phone_number','$c_phone_extension','$c_fax_number')";
	mysql_query($insert_query);
}
else if($_POST['asr_rates'] == 'asr_rates')
{
	extract($_POST);
	$insert_query = "INSERT INTO tbl_asr_rates (c_nickname,asr_rate_amount,asr_rate_eff_start_date,asr_rate_eff_end_date,rt_rate_type) " .
			"values ('$c_nickname','$asr_rate_amount','$asr_rate_eff_start_date','$asr_rate_eff_end_date','$rt_rate_type')";
	mysql_query($insert_query);
}
else if($_POST['agency_agre'] == 'agency_agre')
{
	extract($_POST);
	$insert_query = "INSERT INTO tbl_agency_agreement (qry_lec_companies,whls_carriers,qry_ixc_companies,effective_start_date,effective_end_date) " .
			"values ('$qry_lec_companies','$whls_carriers','$qry_ixc_companies','$effective_start_date','$effective_end_date')";
	mysql_query($insert_query);
}
else if($_POST['nonpooled'] == 'nonpooled')
{
	extract($_POST);
	$insert_query = "INSERT INTO tbl_np_exchange_entry (c_nickname,np_exchange_entry_name) " .
			"values ('$c_nickname','$np_exchange_entry_name')";
	mysql_query($insert_query);
}
?>

<p><h1>Company Management</h1></p>
<div id="accordion" style="margin-top:10px;">
<h3><a href="#section3">Company Information</a></h3>
	<div>
	<form action="index.php?page=company-mang" method="post" id="cmpyinfo">
		<table cellpadding="4">
			<tr>
				<td><strong>Company Name* :</strong></td>
				<td><input type="text" name="c_name" class="required"/></td>
			</tr>
			<tr>
				<td><strong>Company Nickname* :</strong></td>
				<td><input type="text" name="c_nickname" class="required"/></td>
			</tr>
			<tr>
				<td><strong>Company Type* :</strong></td>
				<td>
				<select name="c_type">
				<? while($row = mysql_fetch_array($result)){?>
					<option value=<? echo $row['ct_id'];?> class="required"><? echo $row['ct_company'];?></option>
				<? }?>				
				</select>
				</td>
			</tr>
			<tr>
				<td><strong>Billing Address1 :</strong></td>
				<td><input type="text" name="c_billing_address1"/></td>
			</tr>
			<tr>
				<td><strong>Billing Address2 :</strong></td>
				<td><input type="text" name="c_billing_address2" /></td>
			</tr>
			<tr>
				<td><strong>City :</strong></td>
				<td><input type="text" name="c_billing_city" /></td>
			</tr>
			<tr>
				<td><strong>State :</strong></td>
				<td><input type="text" name="c_billing_state" /></td>
			</tr>
			<tr>
				<td><strong>Zip Code :</strong></td>
				<td><input type="text" name="c_billing_zipcode" /></td>
			</tr>
			<tr>
				<td><strong>Country :</strong></td>
				<td><input type="text" name="c_billing_country" /></td>
			</tr>
			<tr>
				<td><strong>Phone Number :</strong></td>
				<td><input type="text" name="c_phone_number" class="number"/></td>
			</tr>
			<tr>
				<td><strong>Extension :</strong></td>
				<td><input type="text" name="c_phone_extension" class="number"/></td>
			</tr>
			<tr>
				<td><strong>Fax Number :</strong></td>
				<td><input type="text" name="c_fax_number" class="number"/></td>
			</tr>
			<tr>
				<td>&nbsp;<input type="hidden" value="company_info" name="cmpy_info" /></td>
				<td><input type="submit" value="submit" name="submit" /></td>
			</tr>
		</table>
	</form>
	</div>
<? if($_SESSION['user_level'] == 1){?>	
<h3><a href="#asr-rates">ASR Rates</a></h3>
<div>
<form action="index.php?page=company-mang" method="post">
	<table cellpadding="4" cellpadding="0">
		<tr>
			<td><label><strong>LEC Nickname :</strong></label></td>
			<td>
			<select name="c_nickname">
			<? while($row3 = mysql_fetch_array($result3)){?>
				<option value=<? echo $row3['c_nickname'];?>><? echo $row3['c_nickname'];?></option>
			<? }?>
			</select>
			</td>
		</tr>
		<tr>
			<td><label><strong>Rate Type :</label></strong></td>
			<td>
			<select name="rt_rate_type">
				<? while($row2 = mysql_fetch_array($result2)){?>
					<option value=<? echo $row2['rt_rate_type'];?>><? echo $row2['rt_rate_type'];?></option>
				<? }?>	
			</select>
			</td>
		</tr>
		<tr>
			<td><label><strong>Rate* :</label></strong></td>
			<td><input type="text" name="asr_rate_amount" class="required number"/></td>
		</tr>
		<tr>
			<td><label><strong>Effective Start Date* :</label></strong></td>
			<td><input type="text" name="asr_rate_eff_start_date" id="datepicker1" class="required"/></td>
		</tr>
		<tr>
			<td><label><strong>Effective End Date* :</label></strong></td>
			<td><input type="text" name="asr_rate_eff_end_date" id="datepicker2" class="required"/></td>
		</tr>
		<tr>
			<td>&nbsp;<input type="hidden" value="asr_rates" name="asr_rates" /></td>
			<td><input type="submit" value="submit" name="submit" /></td>
		</tr>
	</table>
	</form>
</div>
	<h3><a href="#agency-agreement">Agency Agreement</a></h3>
	<div>
	<form action="index.php?page=company-mang" method="post">
		<table cellpadding="4">
		<tr>
			<td><label><strong>LEC Nickname</strong></label>:</td>
			<td><select name="qry_lec_companies">
										<option value="LEC_company1">LEC company1</option>
										<option value="LEC_company2">LEC company2</option>
										<option value="LEC_company3">LEC company3</option>
										<option value="LEC_company4">LEC company4</option>
									</select></td>
		</tr>
		<tr>
			<td><label><strong>Wholesale Carrier CIC Code :</label></strong></td>
			<td>
			<select name="whls_carriers">
			<? while($row4 = mysql_fetch_array($result4)){?>
				<option value=<? echo $row4['whls_carriers_name'];?>><? echo $row4['whls_carriers_name'];?></option>
			<? }?>
			</select>
			</td>
		</tr>
		<tr>
			<td><label><strong>IXC Nickname :</label></strong></td>
			<td>
			<select name="qry_ixc_companies">
										<option value="LEC_company1">LEC company1</option>
										<option value="LEC_company2">LEC company2</option>
										<option value="LEC_company3">LEC company3</option>
										<option value="LEC_company4">LEC company4</option>
			</select>
			</td>
			</td>
		</tr>
		<tr>
			<td><label><strong>Effective Start Date* :</label></strong></td>
			<td><input type="text" name="effective_start_date" id="datepicker3" class="required"/></td>
		</tr>
		<tr>
			<td><label><strong>Effective End Date* :</label></strong></td>
			<td><input type="text" name="effective_end_date" id="datepicker4" class="required"/></td>
		</tr>
		<tr>
			<td>&nbsp;<input type="hidden" value="agency_agre" name="agency_agre" /></td>
			<td><input type="submit" value="submit" name="submit" /></td>
		</tr>
	</table>
	</form>
	</div>
	
	<h3><a href="#agency-agreement">Non Pooled Exchange forms </a></h3>
	<div>
	<form action="index.php?page=company-mang" method="post">
		<table cellpadding="4">
		<tr>
			<td><label><strong>Company Nickname</strong></label>:</td>
			<td><select name="c_nickname">
										<option value="company1">company1</option>
										<option value="company2">company2</option>
										<option value="company3">company3</option>
										<option value="company4">company4</option>
									</select></td>
		</tr>
		<tr>
			<td><label><strong>Exchange Name* :</label></strong></td>
			<td><input type="text" name="np_exchange_entry_name" class="required"/></td>
		</tr>
		<tr>
			<td>&nbsp;<input type="hidden" value="nonpooled" name="nonpooled" /></td>
			<td><input type="submit" value="submit" name="submit" /></td>
		</tr>
	</table>
	</form>
	</div>
<? }?>
</div>
